package com.zhilifang.modules.zlf.controller;

import java.util.List;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zhilifang.modules.zlf.entity.Lineask;
import com.zhilifang.modules.zlf.service.impl.LineaskServiceImpl;
import com.zhilifang.modules.zlf.utils.Pager;
import com.zhilifang.modules.zlf.utils.QueryString;
import com.zhilifang.modules.zlf.utils.Result;

/**
 * Controller 后台首页>>询盘管理Controller
 */
@Controller
@RequestMapping("/lineaskController")
public class LineaskController {

	@Autowired
	private LineaskServiceImpl lineaskServiceImpl;
	
	
	
	
	/**
	 * 新增询盘
	 * 
	 * @return
	 */
	@RequestMapping(value = "/insertLineask", method = RequestMethod.POST)
	@ResponseBody
	public Result insertLineask(Lineask lineask){
		Result result = new Result();
		lineaskServiceImpl.insertLineask(lineask);
		result.setMessage("新增成功");
		result.setState("200");
		return result;
	}


	/**
	 * 询盘列表
	 * 
	 * @return
	 */
	@RequestMapping(value = "/selectPagerListQueryString", method = RequestMethod.POST)
	@ResponseBody
	public Pager<Lineask> selectPagerListQueryString(QueryString queryString){
		Pager<Lineask> pager = new Pager<Lineask>();
		if(!"".equals(queryString.getReady01())&&queryString.getReady01()!=null){
			queryString.setReady01(queryString.getReady01());  //查询字段 1.姓名 2.电话 3.内容
		}
		if(!"".equals(queryString.getReady02())&&queryString.getReady02()!=null){
			queryString.setReady02("%"+queryString.getReady02()+"%");  //查询内容
		}
		List<Lineask> list = lineaskServiceImpl.selectPagerListQueryString(queryString);
		if (list != null&&!list.isEmpty()) {
			pager=new Pager<Lineask>(queryString.getCurrentPage(),queryString.getPageSize(), list);
		}
		return pager;
	}
	
	
	/**
	 * 删除&批量删除
	 * 
	 * @return
	 */
	@RequestMapping(value = "/deleteLineaskIds", method = RequestMethod.POST)
	@ResponseBody
	public Result deleteLineaskIds(int [] ids){
		Result result = new Result();
		lineaskServiceImpl.deleteLineaskIds(ids);	
		result.setMessage("删除成功");
		result.setState("200");
		return result;
	}

	
	/**
	 * 查询详情
	 * 
	 * @return
	 */
	@RequestMapping(value = "/selectLineaskById", method = RequestMethod.POST)
	@ResponseBody
	public Lineask selectLineaskById(int  id){
		Lineask  lineask = lineaskServiceImpl.selectLineaskById(id);
		return lineask;
	}

}
